import request from '../utils/request.js'

// 查询用户待办任务
export function queryUserTasks(username) {
  return request({
    url: '/flowable-server/workflow/queryUserFlow',
    method: 'post',
    params: { userName: username }
  })
}

// 查询用户已办任务
export function queryCompletedTasks(username) {
  return request({
    url: '/flowable-server/workflow/queryCompletedTasks',
    method: 'post',
    params: { userName: username }
  })
}

// 通过审批
export function approveTask(taskId) {
  return request({
    url: '/flowable-server/workflow/acceptFlow',
    method: 'post',
    params: { taskId }
  })
}

// 拒绝审批
export function rejectTask(taskId, reason) {
  return request({
    url: '/flowable-server/workflow/rejectFlow',
    method: 'post',
    params: { taskId, reason }
  })
}

// 获取审批历史记录
export function getApprovalHistory(params) {
  return request({
    url: '/flowable-server/workflow/approvalHistory',
    method: 'post',
    data: params
  })
}

// 获取审批统计信息
export function getApprovalStatistics(userName) {
  return request({
    url: '/flowable-server/workflow/approvalStatistics',
    method: 'post',
    params: { userName }
  })
}

// 完成任务（带变量）
export function completeTask(taskId, variables) {
  return request({
    url: '/flowable-server/workflow/completeFlow',
    method: 'post',
    params: { taskId },
    data: variables
  })
}


